package cn.lwj.webService.init;

import cn.lwj.webService.webService.impl.DemoWebServiceImpl;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import javax.xml.ws.Endpoint;
import org.apache.log4j.Logger;

@WebListener
public class initServlet1 implements ServletContextListener{
    private Logger log= Logger.getLogger(this.getClass());

    // 系统初始化执行方法
    public void contextDestroyed(ServletContextEvent e) {
        log.info("系统停止...");
    }

    public void contextInitialized(ServletContextEvent e) {
        try {
            System.out.println("哈哈哈哈哈哈哈哈哈哈哈初始化");
            //通过监听类发布webservice
            //定义webService的发布地址111
            //String address = "http://149.0.45.31:8086/demoWebService/";
            String address = "http://192.168.3.16:8086/demoWebService/";
            Endpoint.publish(address, new DemoWebServiceImpl());
            System.out.println("webService发布成功!");
        } catch (Exception e1) {
            e1.printStackTrace();
        } finally{
            log.info("系统初始化结束...");
        }

    }
}
